﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.货号管理.service
{
    public class 成衣异常Service
    {
        /// <summary>
        /// 新增异常
        /// </summary>
        /// <param name="barcode"></param>
        /// <param name="mnemonic"></param>
        /// <param name="wbsCode"></param>
        /// <param name="garmentExceptionDTOList"></param>
        public static int saveGenerateGarmentException(
            String barcode,
            String mnemonic,
            String wbsCode,
            List<GarmentExceptionDTO> garmentExceptionDTOList)
        {
            String re = RestCall.PostHttp(
                        URL.接口url + "/routine_exception/saveGenerateGarmentException?barcode=" + barcode
                                    + "&mnemonic=" + mnemonic
                                    + "&wbsCode=" + wbsCode,
                        FunctionHelper.JsonSerialization(garmentExceptionDTOList)
                        );
            return
                FunctionHelper.JsonDeserialization<int>(
                    re
                    );
        }
        /// <summary>
        /// 查询未放行的异常title列表
        /// </summary>
        /// <returns></returns>
        public static List<GarmentExceptionLogDTO> getGarmentExceptionLogsBySolvedFalse()
        {
            return
                FunctionHelper.JsonDeserialization<List<GarmentExceptionLogDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/routine_exception/getGarmentExceptionLogsBySolvedFalse"
                        )
                    );
        }
        /// <summary>
        /// 根据titleid查询成衣异常详细信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static List<GarmentExceptionLogDetailDTO> getGarmentExceptionLogDetailsByTitleId(String titleid)
        {
            return
                FunctionHelper.JsonDeserialization<List<GarmentExceptionLogDetailDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/routine_exception/getGarmentExceptionLogDetailsByTitleId?id=" + titleid
                        )
                    );
        }
        /// <summary>
        /// 解决异常
        /// </summary>
        /// <param name="id"></param>
        /// <param name="mnemonic"></param>
        /// <returns></returns>
        public static int solveGarmentExceptionLog(String id,String mnemonic)
        {
            return
                FunctionHelper.JsonDeserialization<int>(
                    RestCall.httpGetMethod(
                        URL.接口url + "/routine_exception/solveGarmentExceptionLog?id=" + id + "&mnemonic=" + mnemonic
                        )
                    );
        }
    }

    /// <summary>
    /// 异常列表DTO
    /// </summary>
    public class GarmentExceptionDTO
    {
        public String loginfo { get; set; }   //  异常，描述信息
        public String craftDesignsId { get; set; }  //  工艺设计id
        public GarmentExceptionDTO()
        {

        }

        public GarmentExceptionDTO(string loginfo, string craftDesignsId)
        {
            this.loginfo = loginfo;
            this.craftDesignsId = craftDesignsId;
        }
    }

    /// <summary>
    /// 异常信息title信息DTO
    /// </summary>
    public class GarmentExceptionLogDTO
    {
        public int id { get; set; }
        public String garmentExceptionCode { get; set; }    //  异常编码
        public DateTime createDate { get; set; }
        public String barcode { get; set; } //  成衣码
        /**
        * 销售渠道信息
        */
        public String salesType { get; set; }   //  销售方式    top.toptimus.constValue.SalesTypeConsts
        public String salesChannel { get; set; }    //  销售渠道
        /**
        * 客户信息
        */
        public String customerId { get; set; }
        public String customerName { get; set; }    //  客户姓名
        public String consignee { get; set; }   //  收件人
        public String mobile { get; set; }
        /**
         * 门店信息
         */
        public String shopId { get; set; }
        public String shopName { get; set; }
        /**
         * 款式信息
         */
        public String inventoryNo { get; set; } //  货号
        public String styleCode { get; set; } //  款码
        public String styleCategoryCd { get; set; }
        /**
         * 面料信息
         */
        public String styleFabricId { get; set; }//面料id
        public String materialNameCn { get; set; }//面料描述名称
        public String materialCode { get; set; }  //面料号
        public String composition { get; set; }//面料成分

        //  放行信息
        public Boolean solved { get; set; }
        public String solvedCode { get; set; }
        public String solvedName { get; set; }
        public String solvedMnemonic { get; set; }
        public GarmentExceptionLogDTO()
        {

        }
    }
    /// <summary>
    /// 异常详细信息DTO
    /// </summary>
    public class GarmentExceptionLogDetailDTO
    {
        public String id { get; set; }
        public int titleid { get; set; }    //  
                                            //  WBS模板信息
        public String activityDescription { get; set; } //  工作描述
        public String wbsCode { get; set; }  //  WBS编码顺序
                                             //  分录信息
        public String loginfo { get; set; }    //  异常，描述信息
        public String imagePath { get; set; }   //  异常图片
                                                //  报异常员工信息
        public String code { get; set; }
        public String name { get; set; }
        public String mnemonic { get; set; }
        //  工艺信息
        public String craftDesignsId { get; set; }  //  工艺设计id
        public String craftType { get; set; }//工艺类别
        public String styleCode { get; set; } //  款号
        public String partId { get; set; }  //  部位id 
        public String partDesc { get; set; }    //  部位描述
        public String craftDesignId { get; set; }   //  设计点项id
        public String craftDesignCode { get; set; }    //  设计点项编码
        public String craftDesignDesc { get; set; }    //  设计点项描述
        public GarmentExceptionLogDetailDTO()
        {

        }
    }
}
